package com.yyd.util.redishelper;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.ReadMode;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class RedisHelperApplication {

    public static void main(String[] args) {
        SpringApplication.run(RedisHelperApplication.class, args);
    }

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();

        //指定编码，默认编码为org.redisson.codec.JsonJacksonCodec
        //config.setCodec(new org.redisson.client.codec.StringCodec());
        config.useSingleServer()
                .setAddress("redis://172.20.6.101:6379")
                .setPassword("")
//                .setAddress("redis://127.0.0.1:6379")
                .setConnectionPoolSize(5)
                .setConnectionMinimumIdleSize(4)
                .setIdleConnectionTimeout(10000)
                .setConnectTimeout(3000)
                .setTimeout(3000)
                .setDatabase(0);

        return Redisson.create(config);
    }
}